<template>
	<view class="message">
		<view class="">
			<plate-input :list="list" :fileds="['name']" @onSelect="lll">
			
			</plate-input>
		</view>
		
		
		
		

	</view>
</template>
<script>
	import plateInput from '@/pagesA/common/a-indexed-list/a-indexed-list.vue';
	import store from "@/store/index.js"
	export default {
		components: {
			plateInput
		},
		data() {
			return {
				list: [],
				show1: false,
				content: '',
				clickTrue: '',
				objValue: '',
				
			}
		},
		onLoad(option) {
			uni.showLoading({
				title: '加载中',
				mask: true,
				icon: 'loading',
			});
			this.objValue = option
			
			var listVal = []
			if (option.id == 1) {
				listVal = []
				this.$request('getInsCompanyList', {}, 'get', {}).then(res => {
					for (let item of Object.entries(res.data)) {
						var obj = {
							'letter': '',
							'data': []
						}
						item[1].data.forEach(i => {
							i.name = i.insCompanyName
						})
						obj.letter = item[0]
						obj.data = item[1].data
						listVal.push(obj)
					}
					this.list = listVal
					 uni.hideLoading();
				})
			} else if (option.id == 2) {
				listVal = []
				this.$request('getProvinceList', {}, 'get').then(res => {
					for (let item of Object.entries(res.data)) {
						var obj = {
							'letter': '',
							'data': []
						}
						item[1].data.forEach(i => {
							i.name = i.regionName
						})
						obj.letter = item[0]
						obj.data = item[1].data
						listVal.push(obj)
					}
					this.list = listVal
					 uni.hideLoading();
				})
			} else if (option.id == 3) {
				listVal = []
				this.$request('getCityListByProvinceCode', {
					regionCode: option.regionCode
				}, 'get').then(res => {
					for (let item of Object.entries(res.data)) {
						var obj = {
							'letter': '',
							'data': []
						}
						item[1].data.forEach(i => {
							i.name = i.regionName
						})
						obj.letter = item[0]
						obj.data = item[1].data
						listVal.push(obj)
					}
					this.list = listVal
					 uni.hideLoading();
				})
			}else if (option.id == 4) {
				listVal = []
				this.$request('getCarBrandList', 'get').then(res => {
					for (let item of Object.entries(res.data)) {
						var obj = {
							'letter': '',
							'data': []
						}
						item[1].data.forEach(i => {
							i.name = i.carBrandName
						})
						obj.letter = item[0]
						obj.data = item[1].data
						listVal.push(obj)
					}
					this.list = listVal
					 uni.hideLoading();
				})
			}else if (option.id == 5) {
				listVal = []
				this.$request('getCarClassByBrand',{
					carBrand:option.regionCode
				}, 'get').then(res => {
					for (let item of Object.entries(res.data)) {
						var obj = {
							'letter': '',
							'data': []
						}
						item[1].data.forEach(i => {
							i.name = i.carClassName
						})
						obj.letter = item[0]
						obj.data = item[1].data
						listVal.push(obj)
					}
					this.list = listVal
					 uni.hideLoading();
				})
			}else if (option.id == 6) {
				listVal = []
				this.$request('getCarTypeByClass',{
					carClass:option.regionCode
				}, 'get').then(res => {
					for (let item of Object.entries(res.data)) {
						var obj = {
							'letter': '',
							'data': []
						}
						item[1].data.forEach(i => {
							i.name = i.carTypeName
						})
						obj.letter = item[0]
						obj.data = item[1].data
						listVal.push(obj)
					}
					this.list = listVal
					 uni.hideLoading();
				})
			}else if (option.id == 7) {
				listVal = []
				this.$request('getCarSubtypeByType',{
					carType:option.regionCode
				}, 'get').then(res => {
					for (let item of Object.entries(res.data)) {
						var obj = {
							'letter': '',
							'data': []
						}
						item[1].data.forEach(i => {
							i.name = i.carSubtypeName
						})
						obj.letter = item[0]
						obj.data = item[1].data
						listVal.push(obj)
					}
					this.list = listVal
					 uni.hideLoading();
				})
			}


		},
		methods: {
			lll(item, index, cindex) {
				
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let nowPage = pages[pages.length - 1]; //当前页页面实例
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				if (this.objValue.id == 2) {

					prevPage.$vm.userInfo.repairProvinceName = item.regionName;
					prevPage.$vm.userInfo.repairProvince = item.regionCode;
					prevPage.$vm.userInfo.regionCode = item.regionCode;
					prevPage.$vm.documentId = item.regionCode;
				} else if (this.objValue.id == 3) {
					prevPage.$vm.userInfo.repairCityName = item.regionName;
					prevPage.$vm.userInfo.repairCity = item.regionCode;

				} else if (this.objValue.id == 1) {
					prevPage.$vm.userInfo.insCompanyName = item.insCompanyName;
					prevPage.$vm.userInfo.insCompanyId = item.id;

				}else if (this.objValue.id == 4) {
					prevPage.$vm.userInfo.carBrandName = item.carBrandName;
					prevPage.$vm.userInfo.carBrand = item.carBrand;

				}else if (this.objValue.id == 5) {
					prevPage.$vm.userInfo.carClassName = item.carClassName;
					prevPage.$vm.userInfo.carClass = item.carClass;

				}else if (this.objValue.id == 6) {
					prevPage.$vm.userInfo.carTypeName = item.carTypeName;
					prevPage.$vm.userInfo.carType = item.carType;

				}else if (this.objValue.id == 7) {
					prevPage.$vm.userInfo.carSubtypeName = item.carSubtypeName;
					prevPage.$vm.userInfo.carSubtype = item.carSubtype;

				}


				uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
					delta: 1
				});
			},
			confirmTrue() {
				// B页面

				this.show = false
			}


		}
	}
</script>
